<?php
session_start();
require_once( 'user_db.php' );
 
$m_emp = new M_User();
$user_id = $_SESSION['userid'];

if (isset($_POST['m'])  &&  $_POST['m']!=""){

    if ($_POST['m']== 'login'){
		$user = $_POST['u'];
		$passwd = $_POST['p'];
		 //print_r('test');
		$val=$m_emp->Login($user, $passwd);
		
		if ($val == 1){
			$rows=$m_emp->getUserLoginDetail();
			
			//
			$_SESSION['login_date'] = $rows['login_date'];
			$_SESSION['username'] = $rows['username'];
			$_SESSION['userid'] = $rows['id'];
			$_SESSION['login_name'] = $rows['name'];
			$_SESSION['permission']	=$m_emp->CheckUserAuthen($rows['id']);
			$_SESSION['permission']['dashboard.php']['v']=1;	
			$_SESSION['permission']['register_detail.php']['v']=1;					
			$_SESSION['permission']['student_detail.php']['v']=1;		
			
		} 
		
		 $result= array('result'=>$val);
        
        echo json_encode( $result );
      
    }  
	    
} 
?>